package bot;

import javax.swing.JFrame;

import view.ChatOverviewPanel;

public class ChatBot extends CommandBot {
	ChatOverviewPanel view;

	public ChatBot(ChatOverviewPanel view) {
		super();
		this.view = view;
	}

	public void onMessage(String channel, String sender, String login,
			String hostname, String message) {
		super.onMessage(channel, sender, login, hostname, message);
		view.addText(channel, sender, message);
	}
	public void onPrivateMessage(String sender, String login,
			String hostname, String message) {
		super.onPrivateMessage(sender, login, hostname, message);
		view.addText(sender, message);
	}
	
	public void onAction(String channel, String sender, String login, String hostname, String message) {
		view.addText(sender, message);
	}
	
	@Override
	public void onJoin(String channel, String sender, String login, String hostname) {
		super.onJoin(channel, sender, login, hostname);
		String nick = sender;
		if(sender == this.getNick()) {
			nick = "You've";
		}
		view.addText(channel, "System", nick+" joined the channel");
	}
	
	public static void main(String[] args) throws Exception {
		JFrame frame = new JFrame();
		ChatOverviewPanel view = new ChatOverviewPanel();
		frame.add(view);
		frame.setContentPane(view);
		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		frame.setSize( 500, 400);
		frame.setTitle( "Bot client" );
		frame.setVisible( true );
		ChatBot bot = new ChatBot(view); // Now start our bot up.
		view.setBot(bot);
		bot.setVerbose(true); // Enable debugging output.
	}
}
